package com.wml.java.bookman.framework;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wml.java.bookman.exception.UnAuthorizedException;


@ControllerAdvice
public class ExceptionsHandler {
    @ResponseBody
    @ExceptionHandler(UnAuthorizedException.class)//可以直接写@ExceptionHandler,不指明异常类，会自动映射
    public Result<String> customGenericExceptionHnadler(UnAuthorizedException exception){ //还可以声明接收其他任意参数
        return ResultUtil.fail(Integer.valueOf(exception.getErrorCode()),exception.getErrorMessage());
    }
}
